[][src]Crate icu_testdata

icu_testdata is a unit testing package for ICU4X.

The package exposes a DataProvider with stable data useful for unit testing. The data is based on a CLDR tag and a short list of locales that, together, cover a range of scenarios.

See README.md for instructions on re-generating the data from CLDR.

Examples

use std::borrow::Cow;
use icu_provider::prelude::*;
use icu_provider::structs::plurals::PluralRuleStringsV1;
use icu_locid_macros::langid;

let data_provider = icu_testdata::get_provider();

let data: Cow<PluralRuleStringsV1> = data_provider
    .load(&DataRequest {
        data_entry: DataEntry {
            langid: langid!("be"),
            variant: None,
        },
        data_key: icu_data_key!(plurals: cardinal@1),
    })
    .unwrap()
    .take_payload()
    .unwrap();
assert_eq!(data.few, Some(Cow::Borrowed("n % 10 = 2..4 and n % 100 != 12..14")));

Functions

get_provider

Get a DataProvider loading from test data. Panics if unable to load the data.